#ifndef MESSAGE_H
#define MESSAGE_H
#include <QObject>
#include <QList>
#include "discdata.h"
#include "moviedata.h"

class Message
{
public:
    Message();
    enum MessageIndex
    {
        START,
        STOP,
        STATUS_READY,
        STATUS_WORKING,
        STATUS_DONE,
        PROGRESS,
        DISC_DATA,
        MOVIE_DATA,
        DISC_DATA_UNKNOWN,
        MOVIE_DATA_UNKNOWN,
        SEARCH_MOVIE_DATA,
        SEARCH_DISC_TITLE_DATA,
        STATUS_IDLE
    };

    static const char CTRL_STX = 0x02;
    static const char CTRL_ETX = 0x03;
    static const char CTRL_COMMA = 0x2C;
    static const char CTRL_EQUAL = 0x3D;
    static const char CTRL_PIPE = 0x7C;
    static const char CTRL_FS = 0x1C;//file separator
    static const char CTRL_GS = 0x1D;//group separator
    static const char CTRL_RS = 0x1E;//record separator
    static const char CTRL_US = 0x1F;//unit separator

    static const char MSG_START             = 0xA0;
    static const char MSG_STOP              = 0xA1;
    static const char MSG_STATUS_READY      = 0xA2;
    static const char MSG_STATUS_WORKING    = 0xA3;
    static const char MSG_STATUS_DONE       = 0xA4;
    static const char MSG_PROGRESS          = 0xA5;
    static const char MSG_DISC_DATA         = 0xA6;
    static const char MSG_MOVIE_DATA        = 0xA7;
    static const char MSG_DISC_DATA_UNKNOWN     = 0xA8;
    static const char MSG_MOVIE_DATA_UNKNOWN    = 0xA9;
    static const char MSG_SEARCH_MOVIE_DATA         = 0xAA;
    static const char MSG_SEARCH_DISC_TITLE_DATA    = 0xAB;
    static const char MSG_STATUS_IDLE       = 0xAC;

    static const QByteArray DSC_START;//            = "<STX><MSG_START><CTRL_RS><DATA_START><ETX>";
    static const QByteArray DSC_STOP;//             = "<STX><MSG_STOP><ETX>";
    static const QByteArray DSC_STATUS_READY;//     = "<STX><MSG_STATUS_READY><ETX>";
    static const QByteArray DSC_STATUS_WORKING;//   = "<STX><MSG_STATUS_WORKING><ETX>";
    static const QByteArray DSC_STATUS_DONE;//      = "<STX><MSG_STATUS_DONE><ETX>";
    static const QByteArray DSC_PROGRESS;//         = "<STX><MSG_PROGRESS><CTRL_RS><INT_VALUE><ETX>";
    static const QByteArray DSC_DISC_DATA;//        = "<STX><MSG_DISC_DATA><CTRL_RS><DATA_DISC_DATA_1><CTRL_RS>...<CTRL_RS><DATA_DISC_DATA_N><ETX>";
    static const QByteArray DSC_MOVIE_DATA;//       = "<STX><MSG_MOVIE_DATA><CTRL_RS><DATA_MOVIE_DATA_1><CTRL_RS>...<CTRL_RS><DATA_MOVIE_DATA_N><ETX>";
    static const QByteArray DSC_DISC_DATA_UNKNOWN;//    = "<STX><MSG_DISC_DATA_UNKNOWN><ETX>";
    static const QByteArray DSC_MOVIE_DATA_UNKNOWN;//   = "<STX><MSG_MOVIE_DATA_UNKNOWN><ETX>";
    static const QByteArray DSC_SEARCH_MOVIE_DATA;//    = "<STX><MSG_SEARCH_MOVIE_DATA><CTRL_RS><DATA_MOVIE_DATA><ETX>";
    static const QByteArray DSC_SEARCH_DISC_TITLE_DATA;//    = "<STX><MSG_SEARCH_DISC_TITLE_DATA><CTRL_RS>TITLE=<TEXT><CTRL_US>COUNTRY=<TEXT><CTRL_US>TYPE=<DATA_TYPE><ETX>";


    static const QByteArray DATA_DISC_DATA;//   = "ID=<TEXT><CTRL_US>TITLE=<TEXT><CTRL_US>COUNTRY=<TEXT><CTRL_US>RIPPED=<VALUE><CTRL_US>BOXTITLE=<TEXT><CTRL_US>EDITION=<TEXT><CTRL_US>DESCRIPTION=<TEXT><CTRL_US>COVER=<TEXT><CTRL_US>DATA_DISCS=<DATA_DISCS>";
    static const QByteArray DATA_DISCS;//       = "<CTRL_FS><DATA_DISC_1>...<CTRL_FS><DATA_DISC_N>";
    static const QByteArray DATA_DISC;//        = "IDA=<TEXT><CTRL_GS>IDB=<TEXT><CTRL_GS>NAME=<TEXT>";

    static const QByteArray DATA_MOVIE_DATA;//  = "ID=<TEXT><CTRL_US>TITLE=<TEXT><CTRL_US>COUNTRY=<TEXT><CTRL_US>YEAR=<TEXT><CTRL_US>RIPPED=<VALUE>";

    static const QByteArray DATA_START;//       = "ID=<TEXT><CTRL_US>IDA=<TEXT><CTRL_US>IDB=<TEXT><CTRL_US>ADULT=<BOOLEAN>";
    static const QByteArray DATA_TYPE;//    = "DVD||BLURAY";


    static QList<QByteArray> getAllMessages();

    static QByteArray getMessage(int messageId,QString messageText="");
    static QByteArray getProgressMessage(int progress);
    static QByteArray getDiscDataMessage(QList<DiscData> discDataList);
    static QByteArray getMovieDataMessage(QList<MovieData>);

    //Parsing
    static QByteArray getMessageMSG(QByteArray messageText);
    static QByteArray getMessageText(QByteArray messageText);
    static MovieData getMessageMovieData(QByteArray message);
    static QList<MovieData> getMessageMovieDataList(QByteArray message);
    static DiscData getMessageDiscData(QByteArray message);
    static QList<DiscData> getMessageDiscDataList(QByteArray message);

private:
    static QByteArray makeDataDisc(DiscData discData);
    static QByteArray makeMovieDisc(MovieData movieData);
    static QByteArray makeDataDisc(Disc disc);
    static QByteArray makeDataDiscs(Discs discs);
    static QByteArray makeDataDiscTitle(DiscTitle discTitle);




};

#endif // MESSAGE_H
